package me.sauce.folkpocket48.home.refresh;


import android.app.Application;
import android.databinding.ObservableBoolean;
import android.databinding.ObservableField;
import android.os.Handler;
import android.os.Looper;

import com.orhanobut.logger.Logger;

import org.jetbrains.annotations.NotNull;

import me.sauce.folkpocket48.base.BaseViewModel;

/**
 * @author sauceWu
 * @since 2018/1/2 18:15
 */
public class RefreshViewModule extends BaseViewModel {
    public RefreshViewModule(@NotNull Application application) {
        super(application);
    }

    public ObservableField<String> time = new ObservableField<>(String.valueOf(System.currentTimeMillis()));
    public ObservableBoolean dataLoading = new ObservableBoolean(false);

    @Override
    public void loadData(boolean b) {
        super.loadData(b);
//        dataLoading.set(true);
        time.set(String.valueOf(System.currentTimeMillis()));
        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public void run() {
                Logger.w("ok");
//                dataLoading.set(false);
            }
        }, 1000);
    }

    public void onLeftClick() {
        Logger.w("onclick1");
        time.set(String.valueOf(System.currentTimeMillis()));

    }
}
//class RefreshViewModule(application: Application) : BaseViewModle(application) {
//    var time = ObservableField<String>(System.currentTimeMillis().toString())
//    var dataLoading = ObservableBoolean(false)
//    override fun loadData(b: Boolean) {

//        time.addOnPropertyChangedCallback(object : Observable.OnPropertyChangedCallback() {
//            override fun onPropertyChanged(p0: Observable?, p1: Int) {
//
//            }
//        })
//    }
//
//    fun onLeftClick(view: View) {
//        Logger.w("onclick1")
//        time.set(System.currentTimeMillis().toString())
//        dataLoading.set(false)
//    }
//}
